/**
 * 
 */
package com.kexinde.wjifen.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.kexinde.wjifen.dao.impl.WorkerDao;
import com.kexinde.wjifen.model.Worker;
import com.kexinde.wjifen.service.IWorkerManager;

/**
 * @author vincent
 *
 */
@Component("workerManager")
public class WorkerManager implements IWorkerManager {
	
	private WorkerDao workerDao;

	@Override
	public List<Worker> showAllWorkers(String shopkeeperUserName) {
		// TODO Auto-generated method stub
		return this.workerDao.findAll("Worker", 1, 3);
	}

	@Override
	public Worker showWorker(String workerUserName) {
		// TODO Auto-generated method stub
		return this.workerDao.findByName(workerUserName);
	}

	@Override
	public boolean add(Worker worker) {
		// TODO Auto-generated method stub
		return this.workerDao.doInsert(worker);
	}

	@Override
	public boolean delete(Worker worker) {
		// TODO Auto-generated method stub
		return this.workerDao.doDelete(worker);
	}

	@Override
	public boolean modify(Worker worker) {
		// TODO Auto-generated method stub
		return this.workerDao.doUpdate(worker);
	}

	@Override
	public boolean check(String workerUserName, String workerPassword) {
		// TODO Auto-generated method stub
		boolean result=false;
		Worker worker=this.workerDao.findByName(workerUserName);
		if(workerPassword.equals(worker.getPassword()))
			result=true;
		return result;
	}

	@Override
	public boolean exist(String workerUserName) {
		// TODO Auto-generated method stub
		boolean result=false;
		Worker worker=this.workerDao.findByName(workerUserName);
		if(null!=worker)
			result=true;
		return result;
	}

	public WorkerDao getWorkerDao() {
		return workerDao;
	}
	@Resource
	public void setWorkerDao(WorkerDao workerDao) {
		this.workerDao = workerDao;
	}


}
